#!/bin/bash
echo " ################"
echo " ## install wvdial offline ###"
echo "Author  :Alok "
echo "Version : 0.2"
echo "blog : http://alokandlinux.blogspot.com"
echo "A utility to download and install wvdial in your machine"
sleep 2
echo "starting this may take soem time so pease don't  panic "

if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

# install now 
function installnow(){
	apt-get update 
  apt-get install wvdial -y
	echo "done! installed "
	echo "now connect your modem and type wvdialconf in terminal to configure !"
	echo "enjoy!" 
 
}
# function presence

function presence(){
whereis wvdial | grep /usr/bin/wvdial >> /devnull
if [ "$?" = "0" ]
	then 
		echo already installed !!!
		exit
else  
		installnow
fi
}
# function offline 
function offline () {
# chek for dir

rmdir --ignore-fail-on-non-empty wvdial/
mkdir wvdial 
chmod 777 wvdial
cd wvdial
wget http://alokyadav15.googlecode.com/svn/wvdial.tar
tar -xvzf 
wget http://code.google.com/p/alokyadav15/svn/offline.sh
chmod +x offline.sh
echo "copy wvdial directory to another box and run offline.sh script "
exit 
}
echo "Do you want to install wvdial in this machine or in another machine "
echo "answer with online  or offline"
echo ans : 
read ans
if [ "$ans" = "online" ]
then 
	# testing presence
	presence
else 
	offline
fi 

#END
